# Maintainer: Anjandev Momi <anjan@momi.ca>
pkgname=codemadness-frontends
pkgver=0.6
pkgrel=4
pkgdesc="Experimental (cli, web, and gopher) frontends for youtube, reddit, & duckduckgo"
url="https://www.codemadness.org/idiotbox.html"
# s390x: libressl
arch="all !ppc64le !s390x"
license="ISC"
# libretls-dev fails here, most likely because of some openssl issue
makedepends="libressl-dev"
options="!check" # Has no tests
source="$pkgname-$pkgver.tar.gz::https://codemadness.org/releases/frontends/frontends-$pkgver.tar.gz"
builddir="$srcdir/frontends-$pkgver"

prepare() {
	sed -i 's/^#FRONTENDS_/FRONTENDS_/g' Makefile
	sed -i 's/^#LIBTLS_/LIBTLS_/g' Makefile
	default_prepare
}

build() {
	make \
		LIBTLS_LDFLAGS="$(pkg-config --libs libtls)" \
		LIBTLS_LDFLAGS_STATIC="$(pkg-config --libs --static libtls)" \
		CFLAGS="$CFLAGS $(pkg-config --cflags libtls)"
}

package() {
	install -Dm755 youtube/cgi $pkgdir/usr/bin/youtube-cgi
	install -Dm755 youtube/gopher $pkgdir/usr/bin/youtube-gopher
	install -Dm755 youtube/cli $pkgdir/usr/bin/youtube-cli

	install -Dm755 duckduckgo/gopher $pkgdir/usr/bin/duckduckgo-gopher
	install -Dm755 duckduckgo/cli $pkgdir/usr/bin/duckduckgo-cli

	install -Dm755 reddit/gopher $pkgdir/usr/bin/reddit-gopher
	install -Dm755 reddit/cli $pkgdir/usr/bin/reddit-cli
}

sha512sums="
6d2a397165037625f567b00834beb9559d7cad910a2cb136dbd6022843708c8683a3659d6e0bbfbe48c7beec83d692385bf01dde692b8f1398b86021aef7b74b  codemadness-frontends-0.6.tar.gz
"
